package com.moon.controller;

import com.moon.dao.THistoryMapper;
import com.moon.dto.TUser;
import com.moon.entity.THistory;
import com.moon.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/history")
@RestController
public class THistoryController {
    @Autowired
    private THistoryMapper tHistoryMapper;
    @RequestMapping("queryHistory")
    public String queryHistory(Long id,HttpServletRequest req){
        TUser user = UserUtils.getCurrUserFromHeader("token", TUser.class, req);

        Example example=new Example(THistory.class);//要查询的表对应的实体类
        Example.Criteria criteria=example.createCriteria();//创建查询标准
        criteria.andEqualTo("auctionId",id).andEqualTo("userId",user.getId());//调用方法，编写自己想要查询的条件
        THistory tHistory = tHistoryMapper.selectOneByExample(example);
        if (tHistory==null) return "";
        else  return "1";

    }

}
